package thread.synchronize;

/**
 * @author liweimin
 * @date 2021/4/28 16:51
 * @since
 */
public class ExceptionLock {
    public static final Object obj = new Object();

    public static void main(String[] args) {

        new Thread(() -> {
            synchronized (obj) {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "==>" + i);
                    if (i == 9) {
                        int j = 1 / 0;
                    }
                }
            }
        }).start();

        new Thread(() -> {
            synchronized (obj) {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName() + "==>" + i);
                }
            }
        }).start();


    }
}
